// See http://docs.sequelizejs.com/en/latest/docs/models-definition/
// for more of what you can do here.
const Sequelize = require('sequelize');
const DataTypes = Sequelize.DataTypes;

module.exports = function (app) {
  const sequelizeClient = app.get('sequelizeClient');
  const periods = sequelizeClient.define('ohlcv_periods', {
    period_id: {
      type: DataTypes.STRING,
      primaryKey: true,
      allowNull: false
    },
    length_seconds: {
      type: DataTypes.INTEGER
    },
    length_months: {
      type: DataTypes.INTEGER
    },
    unit_count: {
      type: DataTypes.INTEGER
    },
    unit_name: {
      type: DataTypes.STRING,
    },
    display_name: {
      type: DataTypes.STRING,
    }
  }, {
    hooks: {
      beforeCount(options) {
        options.raw = true;
      }
    }
  });

  // eslint-disable-next-line no-unused-vars
  periods.associate = function (models) {
    // Define associations here
    // See http://docs.sequelizejs.com/en/latest/docs/associations/
  };

  return periods;
};
